using System;
using System.Collections.Generic;

namespace com.bodurov.CharacterRegionsGenerator
{
    public class Range
    {
        public int From;
        public int To;

        public static Range Process(Range last, int current, List<Range> ranges)
        {
            if(last == null)
            {
                var r = new Range { From = current, To = current };
                ranges.Add(r);
                return r;
            }
            else
            {
                if(last.To == (current - 1))
                {
                    last.To = current;
                }
                else
                {
                    var r = new Range { From = current, To = current };
                    ranges.Add(r);
                    return r;
                }
            }
            return last;
        }
    }
}